<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/content.js?v=1.0.0"></script>
<script src="/js/layui.js"></script>
<script src="/js/plugins/clipboard/clipboard.min.js"></script>
<script src="/js/plugins/layer/layer.min.js"></script>
<script type = "text/javascript">
    // 打开网页就运行js方法
    window.onload = function() {

        // 获取店铺图片地址 判断是多少张图片
        var url = $("#storePhotos").val();
        var arrUrl = url.split(",")

        // 获取第一张图片显示
        for (var i = 0; i < arrUrl.length - 1 ; i ++){
            console.log("for:" + i + "==" + arrUrl[i])
            var url = arrUrl[i].substring(0 ,arrUrl[i].lastIndexOf('.'));
            var suffix = arrUrl[i].substring(arrUrl[i].lastIndexOf('.'));
            var replace = suffix.replace("." , "_min.");
            var minUrl = url + replace;
            $("#imageId").attr("src",minUrl);
            break
        }
    }

    //给图片class绑定事件 点击图片放大
    function  showImg(src){
        var img = new Image;
        var url = src.substring(0 ,src.lastIndexOf('_'));
        var suffix = src.substring(src.lastIndexOf('.'));
        var replace = suffix.replace("_min." , ".");
        var maxUrl = url + replace;
        img.src = maxUrl;
        var width;
        var height
        img.onload = function () {
             width = img.width;
             height = img.height;
            $("#maxImage").attr("style","width:"+ width + "px;height:"+ height  + "px");
        };
        layer.open({
            type: 1,//Page层类型
           area: [ width +'px', height + 'px'],
            title: '',
            shade: 0.6 ,//遮罩透明度
            maxmin: true ,//允许全屏最小化
            anim: 1 ,//0-6的动画形式，-1不开启
            content: '<img id="maxImage" style=" "; src=' + maxUrl + '  />',
            btn: ['yes', 'cancel'],
            yes: function(index, layero) {
                alert("y")
                window.onload = function() {

                    // 获取店铺图片地址 判断是多少张图片
                    var url = $("#storePhotos").val();
                    alert("y:" + url)
                    var arrUrl = url.split(",")

                    // 获取第一张图片显示
                    for (var i = 1; i < 5 - 1 ; i ++){
                        alert(i)
        /*                console.log("for:" + i + "==" + arrUrl[i])
                        var url = arrUrl[i].substring(0 ,arrUrl[i].lastIndexOf('.'));
                        var suffix = arrUrl[i].substring(arrUrl[i].lastIndexOf('.'));
                        var replace = suffix.replace("." , "_min.");
                        var minUrl = url + replace;
                        $("#imageId").attr("src",minUrl);
                        break*/
                    }
                }
            },
            cancel: function() {
                //右上角关闭回调
            }
        });
    }


</script>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                        <input id="id" name="id" th:value="${farmShop.id}" type="hidden">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">联系人姓名：</label>
                            <div class="col-sm-8">
                                <input id="name" name="name" th:value="${farmShop.name}" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">联系人电话：</label>
                            <div class="col-sm-8">
                                <input id="phone" name="phone" th:value="${farmShop.phone}" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">店铺照片：</label>
                            <div class="col-sm-8 ">
                             <input id="storePhotos" name="storePhotos" th:value="${farmShop.storePhotos}"
                                       class="form-control" type="text"  style="display:none">
                                <a class = "view"  href="javascript:void(0)"><img  src=""  alt="" onclick="showImg(this.src)" id = "imageId" /></a>;

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">店铺简介：</label>
                            <div class="col-sm-8">
                                <input id="title" name="title" th:value="${farmShop.title}" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">人均消费：</label>
                            <div class="col-sm-8">
                                <input id="consumption" name="consumption" th:value="${farmShop.consumption}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">住宿:</label>
                            <div class="col-sm-8">
                                <label class="radio-inline">
                                    <input type="radio"
                                           th:field="*{farmShop.accommodation}" name="type" value="1"/>
                                    正常
                                </label>
                                <label class="radio-inline">
                                    <input type="radio"
                                           th:field="*{farmShop.accommodation}" name="type" value="2"/>
                                    禁用
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">美食:</label>
                            <div class="col-sm-8">
                                <label class="radio-inline">
                                    <input type="radio"
                                           th:field="*{farmShop.diningRoom}" name="type" value="1"/>
                                    正常
                                </label>
                                <label class="radio-inline">
                                    <input type="radio"
                                           th:field="*{farmShop.diningRoom}" name="type" value="2"/>
                                    禁用
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">农家名称：</label>
                            <div class="col-sm-8">
                                <input id="farmName" name="farmName" th:value="${farmShop.farmName}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">营业执照：</label>
                            <div class="col-sm-8">
                                <input id="businessLicens" name="businessLicens" th:value="${farmShop.businessLicens}"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">审核状态:</label>
                            <div class="col-sm-8">
                                <label class="radio-inline">
                                    <input type="radio"
                                           th:field="*{farmShop.status}" name="type" value="1"/>
                                    通过
                                </label>
                                <label class="radio-inline">
                                    <input type="radio"
                                           th:field="*{farmShop.status}" name="type" value="2"/>
                                    审核中
                                </label>
                                <label class="radio-inline">
                                    <input type="radio"
                                           th:field="*{farmShop.status}" name="type" value="3"/>
                                    未通过
                                </label>
                            </div>

                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">热度：</label>
                            <div class="col-sm-8">
                                <input id="hotValue" name="hotValue" th:value="${farmShop.hotValue}"
                                       class="form-control" type="text"  readonly="readonly">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">经度：</label>
                            <div class="col-sm-8">
                                <input id="lng" name="lng" th:value="${farmShop.lng}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">纬度：</label>
                            <div class="col-sm-8">
                                <input id="lat" name="lat" th:value="${farmShop.lat}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">详细地址：</label>
                            <div class="col-sm-8">
                                <input id="address" name="address" th:value="${farmShop.address}" class="form-control"
                                       type="text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">热门:</label>
                            <div class="col-sm-8">
                                <label class="radio-inline">
                                    <input type="radio"
                                           th:field="*{farmShop.recommend}" name="type" value="1"/>
                                    热门
                                </label>
                                <label class="radio-inline">
                                    <input type="radio"
                                           th:field="*{farmShop.recommend}" name="type" value="2"/>
                                    未热门
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">上下架</label>
                            <div class="col-sm-8">
                                <label class="radio-inline">
                                    <input type="radio"
                                           th:field="*{farmShop.updownStatus}" name="type" value="1"/>
                                    上架
                                </label>
                                <label class="radio-inline">
                                    <input type="radio"
                                           th:field="*{farmShop.updownStatus}" name="type" value="2"/>
                                    下架
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/js/appjs/farm/farmShop/edit.js"/>
</body>
</html>
